ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ WHAT_DRV.TXT Û ³ Û ßßßßßßßßßßßßßßßßßß Fri 01-28-1994 21:01:00 This file set includes: 1. WHAT_DRV.SCR (code for the *.COM file) 2. MAKE.BAT (runs DEBUG to make the *.COM file) 3. DRIVE.BAT (demonstrates ERRORLEVEL, tells you what drive) 4. WHAT_DRV.COM (put this in for the very, very nervous) 5. WHAT_DRV.TXT (this file) 6. READ.COM (my littlest text file loader) 7. FROMJOHN.BAT (loads this text file with READ.COM) WHAT_DRV.COM file sets an ERRORLEVEL (aka exit code) equal to the drive -number- where this program executes from. What is fascinating to me is that this is =exactly= the same code I recently doped out to make BOOT.BAS and BOOT.COM which does =exactly= the same thing! For those of you who are unimpressed with this, let me say that the ability of a QuickBASIC to =duplicate= an Assembly language program like this one is not a very well known fact. WHAT_DRV.COM finds out what drive this is by CALLing DOS Interrupt 21 to return the drive number: DRIVE Number ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ- A: 0 B: 1 C: 2 D: 3 E: 4 This number is returned to the low byte of the Register AX, the low byte is called AL (the high byte is AH). Now this is the =secret= part.... THIS next bit of information is worth -at least- a Captain Midnight Secret decoder ring and whistle as I have NEVER seen it written so we ordinary mortals could understand it! You now CALL DOS interrupt 21 -again-, but this time you close the program and set the ERRORLEVEL to whatever number is sitting in AL. Well we just put the drive number in there so that's what the ERRORLEVEL is.... how very cute.... The following is a copy of the file WHAT_DRV.SCR with comments to explain what's going on. I haven't figured out how to put comments into a DEBUG Assembly program so this will have to do. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ n WHAT_DRV.COM ;name the file a ;assemble the following commands mov ah,19 ;move Function Hex 19 into AH int 21 ;call MS-DOS Interrupt Hex 21 mov ah,4c ;move the "Return with Exit code" Function into AH int 21 ;call MS-DOS Interrupt Hex 21 ;end the program, by putting an {Enter} here rcx ;display the CX register 8 ;put the number of bytes of the program into CX w ;write the *.COM file q ;quit, make sure there is an {Enter} after this line!! ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ With these files you can make your very own "what drive am I in and that's the drive I want to end up in" batch file set. You can modify DRIVE.BAT to not only tell you what drive you are in but DRIVE.BAT also =stores= that information in an environment variable that you can use to =restore= you back to the drive your batch file started at. I have added all the SET commands to the commands following the LABELs If you were on A: drive when you ran DRIVE.BAT then the environment variable would be set as below: :A echo This drive is A SET DRIVE=A: rem: This makes the variable To end the batch file BACK on A: Drive you would put the following command at the end. eg: %DRIVE% rem: The batch file executes the command "A:" If this is not good enough then I suggest you look up what I did a few months ago. I made a file set with DRIVE.BAS and DRV_BACK.BAS. The executable files in that file set do a similar thing but -more better- as those programs not only return you back to the drive you started on but also to what -directory- you started from. John De Palma on CompuServe 76076,571